﻿using System.Web.Mvc;
using System.Web.Routing;

namespace ECG.WebUI
{
    public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            // Register
            routes.MapRoute(
                    name: "register",
                    url: "dang-ki.html",
                    defaults: new { controller = "Login", action = "Register" }
                );

            // Login
            routes.MapRoute(
                    name: "login",
                    url: "dang-nhap.html",
                    defaults: new { controller = "Login", action = "Index" }
                );

            // Tìm kiếm
            routes.MapRoute(
                    name: "Search",
                    url: "tim-kiem/{keyword}.html",
                    defaults: new { controller = "Search", action = "Index", keyword = UrlParameter.Optional }
                );

            // Khuyen mai
            routes.MapRoute(
                    name: "Promotion",
                    url: "khuyen-mai.html",
                    defaults: new { controller = "PromotionPage", action = "home" }
                );

            // san pham moi
            routes.MapRoute(
                    name: "ProductNew",
                    url: "san-pham-moi-nhat.html",
                    defaults: new { controller = "ProductNew", action = "Index" }
                );

            // thuong hieu theo cate
            routes.MapRoute(
                    name: "ProviderCategory",
                    url: "Provider/thuong-hieu-{CategoryName}-{CategoryId}.html",
                    defaults: new { controller = "ProviderHome", action = "ViewProviderHomeByCate", categoryId = "", categoryName = "" }
                );

            // gio vang
            routes.MapRoute(
                    name: "GoldenTimeProduct",
                    url: "gio-vang.html",
                    defaults: new { controller = "GoldenTimeList", action = "Index" }
                );
            routes.MapRoute(
                    name: "PromotionByCate",
                    url: "khuyen-mai/{CategoryName}-{CategoryId}.html",
                    defaults: new { controller = "Promotion", action = "ProductPromotionByCate", CategoryName = "", CategoryId = "" }
                );

            // Chi tiet san pham
            routes.MapRoute(
                name: "ProductDetail",
                url: "{ProductName}-{ProductId}.html",
                defaults: new { controller = "ProductDetail", action = "Index", productName = "", productId = "" }
            );

            // Danh muc san pham cap 1
            routes.MapRoute(
                name: "ProductByCategoryL1",
                url: "danh-muc/c-1/{CategoryName}-{CategoryId}.html",
                defaults: new { controller = "CategoryL1", action = "Index", CategoryName = "", CategoryId = "" }
            );

            // Danh muc san pham cap 2
            routes.MapRoute(
                name: "ProductByCategory",
                url: "danh-muc/{CategoryName}-{CategoryId}.html",
                defaults: new { controller = "Category", action = "Index", CategoryName = "", CategoryId = "" }
            );

            // Danh muc san pham cap 3
            routes.MapRoute(
                name: "ProductByCategoryL3",
                url: "danh-muc/c-3/{CategoryName}-{CategoryId}.html",
                defaults: new { controller = "CategoryL3", action = "Index", CategoryName = "", CategoryId = "" }
            );

            // San pham theo thuong hieu
            routes.MapRoute(
                name: "ProductByProvider",
                url: "thuong-hieu/{providerName}-{Provider}.html",
                defaults: new { controller = "ProductByProvider", action = "Index", ProviderName = "", Provider = "" }
            );

            // News home
            routes.MapRoute(
                name: "NewsHome",
                url: "n/tin-tuc.html",
                defaults: new { controller = "News", action = "Index" }
            );
			
            // News Cate
            routes.MapRoute(
                name: "NewsCateHome",
                url: "n/{catename}-c{id}.html",
                defaults: new { controller = "News", action = "ListNewsCateHome",  catename = UrlParameter.Optional, id = UrlParameter.Optional }
            );
			
            // News Tag
            routes.MapRoute(
                name: "NewsTag",
                url: "tag/{tagname}-t{id}.html",
                defaults: new { controller = "News", action = "ListNewsTagHome", tagname = UrlParameter.Optional, id = UrlParameter.Optional }
            );
			
            // News detail
            routes.MapRoute(
                name: "NewsDetail",
                url: "d/{newsTitle}-n{id}.html",
                defaults: new { controller = "News", action = "NewsDetail", id = UrlParameter.Optional, newsTitle = UrlParameter.Optional }
            );

            // Product Tag
            routes.MapRoute(
                name: "ProductTag",
                url: "tags/{name}-{id}.html",
                defaults: new { controller = "ProductTag", action = "ProductListByTag", name = UrlParameter.Optional, id = UrlParameter.Optional }
            );

            // Trang chu
            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}",
                defaults: new { controller = "Home", action = "Index" }
            );
        }
    }
}